-
Notifications
You must be signed in to change notification settings - Fork 1
[INC-300] baton-github: include the error in the returned message #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| }, | ||
| }) | ||
| if err != nil { | ||
| if isRatelimited(resp) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I add isRatelimited to Every API calls, including List and Grants
| for { | ||
| orgs, resp, err := client.Organizations.List(ctx, "", &github.ListOptions{Page: page, PerPage: maxPageSize}) | ||
| if err != nil { | ||
| if isRatelimited(resp) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's Validate function, baton-sdk doesn't do the retry for Validate function, I don't know why we have to handle with this error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are adding retry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and also the error message is not correct
can you return an error instead of nil?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, that makes sense. TIL
| orgs, resp, err := o.client.Organizations.List(ctx, "", opts) | ||
| if err != nil { | ||
| if isRatelimited(resp) { | ||
| return nil, "", nil, uhttp.WrapErrors(codes.Unavailable, "too many requests", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. Add isRatelimited to List()
| if err != nil { | ||
| if isRatelimited(res) { | ||
| return nil, "", nil, uhttp.WrapErrors(codes.Unavailable, "too many requests", err) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: GitHub API Client Nil Response Handling
The isRatelimited function is called on GitHub API responses without a preceding nil check. GitHub API client methods can return a nil response object alongside an error (e.g., due to network issues or specific undocumented API behaviors like Users.GetByID), leading to nil pointer dereferences.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isRatelimited has checked nil pointer.
No description provided.